/*
 * @ author madman 
 * @ use 月租记录
 */
const Utils = require('../../utils');
const rentalModel = require('../../../models/nexmo/rental.model');
class Rental {
    // 新增
    async add(ctx) {
      const _body = ctx.request.body
      const _params = Utils._params(_body)
      const result = await rentalModel.create(_params);
      if (result) {
          return ctx.success({ msg: '添加成功' });
      } else {
          return ctx.error({ msg: '添加失败' });
      }
    }
    //获取所有价格配置
    async list(ctx) {
      const options = {
          name: 'nexmo/rental',
          type: 'page',
          findField: {}
      }
      let result = null
      if (ctx.query.msisdn) {
        options.findField.msisdn = ctx.query.msisdn
      }
      result = await Utils.getPageList(ctx, options)
      if (result) {
          return ctx.success({
              data: result,
              msg: '查询成功'
          });
      }
    }
}

export default new Rental;